package com.dmn.gcode.springchains;

import com.dmn.gcode.springchains.core.IOperator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * date 17.01.11
 *
 * @author dvponomarev
 * @version 1.0
 */
public class Main {
    public static void main(String[] args) throws Throwable {
        ApplicationContext context =
            new ClassPathXmlApplicationContext(new String[]{"sequence.xml"});
        IOperator entryPointOperator = (IOperator) context.getBean("entryPoint");

        new ChainMaster().execute(entryPointOperator);

        ChainMasterWithFeedback chainMasterWithFeedback = new ChainMasterWithFeedback();
        chainMasterWithFeedback.addChainEventListener(new IChainEventListener() {
            public void onBeforeOperator(String operatorPath, String operatorName) {
                System.out.println("BEFORE: " + operatorPath + " " + operatorName);
            }

            public void onAfterOperator(String operatorPath, String operatorName) {
                System.out.println("AFTER: " + operatorPath + " " + operatorName);
            }
        });
        chainMasterWithFeedback.execute(entryPointOperator);
    }
}
